//
//  CellForInformationVCSectionOneKindOne.m
//  echo
//
//  Created by dllo on 16/2/26.
//  Copyright © 2016年 Danny. All rights reserved.
//

#define WIDTH [UIScreen mainScreen].bounds.size.width / 414
#define HEIGHT [UIScreen mainScreen].bounds.size.height / 736

#import "CellForInformationVCSectionOneKindOne.h"
#import "ModelForInformationVCSectionOneKindOne.h"
#import <SDWebImage/UIButton+WebCache.h>
#import <DKNightVersion.h>

@interface CellForInformationVCSectionOneKindOne ()
@property (nonatomic, retain)UIView *backView;
@property (nonatomic, retain)UIButton *buttonForVedio;
@property (nonatomic, retain)UILabel *labelForTop;
@property (nonatomic, retain)UILabel *labelForBottom;
@property (nonatomic, retain)UILabel *line;
@end

@implementation CellForInformationVCSectionOneKindOne

- (void)dealloc{
    [_backView release];
    [_buttonForVedio release];
    [_labelForTop release];
    [_labelForBottom release];
    [_line release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backView = [[UIView alloc]init];
        [self.contentView addSubview:self.backView];
        [self.backView release];
        
        self.buttonForVedio = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.backView addSubview:self.buttonForVedio];
        [self.buttonForVedio release];
        
        self.labelForTop = [[UILabel alloc]init];
        [self.backView addSubview:self.labelForTop];
        [self.labelForTop release];
        self.labelForTop.font = [UIFont fontWithName:@"Arial" size:13.0];
        self.labelForTop.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
        
        self.labelForBottom = [[UILabel alloc]init];
        [self.backView addSubview:self.labelForBottom];
        [self.labelForBottom release];
        self.labelForBottom.font = [UIFont fontWithName:@"Arial" size:13.0];
        self.labelForBottom.numberOfLines = 2;
        self.labelForBottom.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
        
        self.line = [[UILabel alloc]init];
        [self.backView addSubview:self.line];
        [self.line release];
        
        [self handleNightModel];
    }
    return self;
}

- (void)passModel:(ModelForInformationVCSectionOneKindOne *)model{
    [self.buttonForVedio sd_setBackgroundImageWithURL:[NSURL URLWithString:model.cover_url] forState:UIControlStateNormal];
    self.labelForTop.text = model.name;
    self.labelForBottom.text = model.info;
}

- (void)handleNightModel{
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"夜间模式"]) {
        
        [DKNightVersionManager nightFalling];
        
    } else {
        
        [DKNightVersionManager dawnComing];
    }
    
    self.backView.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
    self.labelForTop.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
    self.labelForBottom.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
    self.line.dk_backgroundColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.backView.frame = self.contentView.frame;
    
    
    self.buttonForVedio.frame = CGRectMake(35 * WIDTH, 30 * HEIGHT, self.contentView.frame.size.width - 70 * WIDTH, 160 * HEIGHT);
    
    self.labelForTop.frame = CGRectMake(35 * WIDTH, 30 * HEIGHT + 160 * HEIGHT + 10 * HEIGHT, self.contentView.frame.size.width - 70 * WIDTH, 30 * HEIGHT);
    
    self.labelForBottom.frame = CGRectMake(35 * WIDTH, 30 * HEIGHT + 160 * HEIGHT + 10 * HEIGHT + 30 * HEIGHT + 2 * HEIGHT, self.contentView.frame.size.width - 70 * WIDTH, 30 * HEIGHT);

    self.line.frame = CGRectMake(15 * WIDTH, 281 * HEIGHT, self.contentView.frame.size.width - 30 * WIDTH, 1 * HEIGHT);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
